package cn.tedu.lucky.draw.server.repository;

import cn.tedu.lucky.draw.server.protocol.po.Activity;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.time.LocalDateTime;
import java.util.List;

@Repository
public interface ActivityRepository extends JpaRepository<Activity,Long> {
    /**
     * 根据活动名称和活动状态 结合Sort值进行升序排序查询
     */
    List<Activity> findByNameAndStatusOrderBySortDesc(String name,Integer status);


    /**
     * 查询ID在1-5之间的活动数据
     */
    List<Activity> findActivitiesByIdBetween(Long start,Long end);


    Activity findActivityByNameEquals(String name);

    //查询活动状态为启用并且以及超过了结束时间的活动
    Page<Activity> findByStatusAndEndTimeBefore(Integer status, LocalDateTime localDateTime, Pageable pageable);


    List<Activity> findByStatusEquals(Integer status);
}
